package com.yhgm.utils;

import com.yhgm.entity.ImageSearch;
import org.elasticsearch.action.search.SearchRequest;
import org.elasticsearch.index.query.QueryBuilders;

public class QueryBuilder {
    public static SearchRequest createReq(SearchRequest req, ImageSearch imageSearch){
        if(imageSearch.getImageFormat()!=null&&!imageSearch.getImageFormat().equals("")){
            req.source()
                    .query(QueryBuilders.boolQuery()
                            .must(QueryBuilders.matchQuery("imageFormat",imageSearch.getImageFormat())));
        }
        if(imageSearch.getImageOrgan()!=null&&!imageSearch.getImageOrgan().equals("")){
            req.source()
                    .query(QueryBuilders.boolQuery()
                            .must(QueryBuilders.matchQuery("imageOrgan",imageSearch.getImageOrgan())));
        }
        // TODO: 2024/5/20 order info
        return req;
    }
}
